import { assertEquals } from '@std/assert';
import { FakeTime } from '@std/testing/time';
import { lessThan, parse } from '@std/semver';

import { SettingsService } from '../../services/settingsService.ts';
import { verifyRegistrationResponse } from '../verifyRegistrationResponse.ts';
import {
  Google_Hardware_Attestation_Root_1,
  Google_Hardware_Attestation_Root_2,
} from '../../services/defaultRootCerts/android-key.ts';

/**
 * Clear out root certs for android-key since responses were captured from FIDO Conformance testing
 * and have cert paths that can't be validated with known root certs from Google
 */

Deno.test('should verify Android Keystore response from FIDO Conformance in 2020', async () => {
  SettingsService.setRootCertificates({
    identifier: 'android-key',
    certificates: [],
  });

  /**
   * Faking time to something that'll satisfy all of these ranges:
   *
   * {
   *   notBefore: 1970-02-01T00:00:00.000Z,
   *   notAfter: 2099-01-31T23:59:59.000Z
   * }
   * {
   *   notBefore: 2019-04-25T05:49:32.000Z,
   *   notAfter: 2046-09-10T05:49:32.000Z
   * }
   */
  const mockDate = new FakeTime(new Date('2025-01-26T19:00:00.000Z'));

  const verification = await verifyRegistrationResponse({
    response: {
      id: 'V51GE29tGbhby7sbg1cZ_qL8V8njqEsXpAnwQBobvgw',
      rawId: 'V51GE29tGbhby7sbg1cZ_qL8V8njqEsXpAnwQBobvgw',
      response: {
        attestationObject:
          'o2NmbXRrYW5kcm9pZC1rZXlnYXR0U3RtdKNjYWxnJmNzaWdYRzBFAiAbZhfcF0KSXj5rdEevvnBcC8ZfRQlNl9XYWRTiIGKSHwIhAIerc7jWjOF_lJ71n_GAcaHwDUtPxkjAAdYugnZ4QxkmY3g1Y4JZAxowggMWMIICvaADAgECAgEBMAoGCCqGSM49BAMCMIHkMUUwQwYDVQQDDDxGQUtFIEFuZHJvaWQgS2V5c3RvcmUgU29mdHdhcmUgQXR0ZXN0YXRpb24gSW50ZXJtZWRpYXRlIEZBS0UxMTAvBgkqhkiG9w0BCQEWImNvbmZvcm1hbmNlLXRvb2xzQGZpZG9hbGxpYW5jZS5vcmcxFjAUBgNVBAoMDUZJRE8gQWxsaWFuY2UxIjA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          'eyJvcmlnaW4iOiJodHRwczovL2Rldi5kb250bmVlZGEucHciLCJjaGFsbGVuZ2UiOiI0YWI3ZGZkMS1hNjk1LTQ3NzctOTg1Zi1hZDI5OTM4MjhlOTkiLCJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0',
        transports: ['internal'],
      },
      type: 'public-key',
      clientExtensionResults: {},
    },
    expectedChallenge: '4ab7dfd1-a695-4777-985f-ad2993828e99',
    expectedOrigin: 'https://dev.dontneeda.pw',
    expectedRPID: 'dev.dontneeda.pw',
    requireUserVerification: false,
  });

  assertEquals(verification.verified, true);

  mockDate.restore();
});

Deno.test('should verify Android Keystore response from a Pixel 8a in January 2025', async () => {
  SettingsService.setRootCertificates({
    identifier: 'android-key',
    certificates: [Google_Hardware_Attestation_Root_2],
  });

  /**
   * Faking time to something that'll satisfy all of these ranges:
   *
   * {
   *   notBefore: 1970-01-01T00:00:00.000Z,
   *   notAfter: 2048-01-01T00:00:00.000Z
   * }
   * {
   *   notBefore: 2025-01-07T17:08:43.000Z,
   *   notAfter: 2025-02-02T10:35:27.000Z
   * }
   * {
   *   notBefore: 2024-12-09T06:28:53.000Z,
   *   notAfter: 2025-02-17T06:28:52.000Z
   * }
   * {
   *   notBefore: 2022-01-26T22:49:45.000Z,
   *   notAfter: 2037-01-22T22:49:45.000Z
   * }
   * {
   *   notBefore: 2019-11-22T20:37:58.000Z,
   *   notAfter: 2034-11-18T20:37:58.000Z
   * }
   */
  const mockDate = new FakeTime(new Date('2025-02-02T10:00:00.000Z'));

  const verification = await verifyRegistrationResponse({
    response: {
      id: 'AYNe4CBKc8H30FuAb8uaht6JbEQfbSBnS0SX7B6MFg8ofI92oR5lheRDJCgwY-JqB_QSJtezdhMbf8Wzt_La5N0',
      rawId:
        'AYNe4CBKc8H30FuAb8uaht6JbEQfbSBnS0SX7B6MFg8ofI92oR5lheRDJCgwY-JqB_QSJtezdhMbf8Wzt_La5N0',
      response: {
        attestationObject:
          'o2NmbXRrYW5kcm9pZ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F1dGhEYXRhWMVJlg3liA6MaHQ0Fw9kdmBbj-SuuaKGMseZXPO6gx2XY0UAAAAAuT_ZYfLmRi-xIoIAIkfeeABBAYNe4CBKc8H30FuAb8uaht6JbEQfbSBnS0SX7B6MFg8ofI92oR5lheRDJCgwY-JqB_QSJtezdhMbf8Wzt_La5N2lAQIDJiABIVgg11Yt_p_qwbKz9wOD4_T_HujzYd3jXQt_D2hYgmcjFnUiWCBFQOj2xOvfOT0lAw3J5Nyp56cnOuifxxTrv4HrqolrQA',
        clientDataJSON:
          'eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoidDRMV0kwaVlKU1RXUGw5V1hVZE5oZEhBbnJQRExGOWVXQVA5bEhnbUhQOCIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODAwMCIsImNyb3NzT3JpZ2luIjpmYWxzZX0',
      },
      type: 'public-key',
      clientExtensionResults: {
        credProps: { rk: false },
      },
      authenticatorAttachment: 'platform',
    },
    expectedChallenge: 't4LWI0iYJSTWPl9WXUdNhdHAnrPDLF9eWAP9lHgmHP8',
    expectedOrigin: 'http://localhost:8000',
    expectedRPID: 'localhost',
    requireUserVerification: false,
  });

  assertEquals(verification.verified, true);

  mockDate.restore();
});

Deno.test({
  name: 'should verify Android Keystore response from a Samsung Galaxy S9+ running Android 10',
  /**
   * Verifying a SHA256 hash with a P-384 public key, or vice-versa with SHA384 and P-256,
   * isn't supported till Deno v2.2.0. In Deno v2.1, this test will error out with a
   * "Not implemented" error so I'm ignoring this test in older Deno runtimes:
   *
   * https://github.com/denoland/deno/blob/v2.1/ext/crypto/00_crypto.js#L1318-L1326
   */
  ignore: lessThan(parse(Deno.version.deno), parse('2.2.0')),
}, async () => {
  SettingsService.setRootCertificates({
    identifier: 'android-key',
    certificates: [Google_Hardware_Attestation_Root_1],
  });

  /**
   * Faking time to something that'll satisfy all of these ranges:
   *
   * {
   *   notBefore: 1970-01-01T00:00:00.000Z,
   *   notAfter: 2106-02-07T06:28:15.000Z
   * }
   * {
   *   notBefore: 2019-06-13T19:31:18.000Z,
   *   notAfter: 2029-06-10T19:31:18.000Z
   * }
   * {
   *   notBefore: 2019-06-13T19:25:28.000Z,
   *   notAfter: 2029-06-10T19:25:28.000Z
   * }
   * {
   *   notBefore: 2016-05-26T16:28:52.000Z,
   *   notAfter: 2026-05-24T16:28:52.000Z
   * }
   */
  const mockDate = new FakeTime(new Date('2025-07-15T10:00:00.000Z'));

  const verification = await verifyRegistrationResponse({
    response: {
      id: 'AZNJEB2RcdcMJ0kZ1X1lyA6d7ENiKF5K945bpbZXxdVqoyjENSnHSZuxZz9sBMVyKAArpVBhwWr7WTutT_epNsk',
      rawId:
        'AZNJEB2RcdcMJ0kZ1X1lyA6d7ENiKF5K945bpbZXxdVqoyjENSnHSZuxZz9sBMVyKAArpVBhwWr7WTutT_epNsk',
      response: {
        attestationObject:
          'o2NmbXRrYW5kcm9pZC1rZXlnYXR0U3RtdKNjYWxnJmNzaWdYRzBFAiBN6uMvi4Arrog6bM-EH_HHdcYowZb9AZ3OP8LF7BsOwQIhAIGMW51yybiu_p90i60qFilQ2NTBfNSKMxWSd-_ElLGGY3g1Y4RZAsAwggK8MIICYqADAgECAgEBMAoGCCqGSM49BAMCMCkxGTAXBgNVBAUTEDljZmFiZjY5ZWNjMzc0OWMxDDAKBgNVBAwMA1RFRTAgFw03MDAxMDEwMDAwMDBaGA8yMTA2MDIwNzA2MjgxNVowHzEdMBsGA1UEAwwUQW5kcm9pZCBLZXlzdG9yZSBLZXkwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARF-xUruvQrCRWHiRDV4Lsq4FjoEpLFf361IEQaaeBsGuz0zt29H0BKNbEIUpvWcuKBKwmcOvMH2wFAZ7tRHblHo4IBgTCCAX0wDgYDVR0PAQH_BAQDAgeAMIIBaQYKKwYBBAHWeQIBEQSCAVkwggFVAgEDCgEBAgEECgEBBCCtDPAKpMZ9hMbYOO1XIwN-v_gV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yO-aqaSxhva6e1AnUY8TJfGQwZXfu8rx1YLdXFcycfcZ8hggtt1GonDA0l2KweCOFh1zxo8YWbgrjwS03Ti1PGEbzGHRL2Hm1hzKb8BghemwMdyQaSHjkNcAwectFEonFd2IGBpovjWX4QOFEUoe-2HerriTiRDUWjVU85GhhdXRoRGF0YVjFT848GIB1YSy2AgqgP_bEoHGe74fBQecLAfr8oYF8zI5FAAAAALk_2WHy5kYvsSKCACJH3ngAQQGTSRAdkXHXDCdJGdV9ZcgOnexDYiheSveOW6W2V8XVaqMoxDUpx0mbsWc_bATFcigAK6VQYcFq-1k7rU_3qTbJpQECAyYgASFYIEX7FSu69CsJFYeJENXguyrgWOgSksV_frUgRBpp4GwaIlgg7PTO3b0fQEo1sQhSm9Zy4oErCZw68wfbAUBnu1EduUc',
        clientDataJSON:
          'eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoidkNMQVIzQUdoeGZQMFEtTDkyX0JzcHBraEFDYnkwSGp0TlpFQkZKMGdPayIsIm9yaWdpbiI6Imh0dHBzOi8vcG9ydGFsLmZ4b24uY29tIiwiY3Jvc3NPcmlnaW4iOmZhbHNlLCJvdGhlcl9rZXlzX2Nhbl9iZV9hZGRlZF9oZXJlIjoiZG8gbm90IGNvbXBhcmUgY2xpZW50RGF0YUpTT04gYWdhaW5zdCBhIHRlbXBsYXRlLiBTZWUgaHR0cHM6Ly9nb28uZ2wveWFiUGV4In0',
      },
      type: 'public-key',
      clientExtensionResults: { credProps: { rk: false } },
    },
    expectedChallenge: 'vCLAR3AGhxfP0Q-L92_BsppkhACby0HjtNZEBFJ0gOk',
    expectedOrigin: 'https://portal.fxon.com',
    expectedRPID: 'portal.fxon.com',
  });

  assertEquals(verification.verified, true);

  mockDate.restore();
});
